<#assign menu="House">
<#assign menu2="">
<#include "/common/header.ftl">
<#include "/common/sidebar.ftl">

<!-- BEGIN PAGE -->
<div class="page-content">
    <!-- BEGIN PAGE HEADER-->
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN PAGE TITLE & BREADCRUMB-->
            <h3 class="page-title">
                房源管理
            </h3>
            <!-- END PAGE TITLE & BREADCRUMB-->
        </div>
    </div>
    <!-- END PAGE HEADER-->

<#include "/house_source/detail.ftl">
    <div id="FolowAddModal" class="modal fade modal-scroll modal-mid">
        <form class="form-horizontal" id="FolowForm" action="javascript:submitFolow();" autocomplete="off" method="post" role="form">
            <div class="modal-header">
                <button type="button" class="close" onclick="folowCancel();" aria-hidden="true"></button>
                <h4 class="modal-title" id="folow-add-title">新增跟进</h4>
            </div>
            <div class="modal-body">

                <div class="form-group">
                    <label class="col-sm-3 control-label">跟进内容</label>
                    <label class="col-sm-1"></label>
                    <div class="col-sm-7">
                        <textarea class="form-control remark" rows="3" id="folowContent" name="folowContent" placeholder="" ></textarea>
                        <input type="hidden"  name="houseId" id="houseId" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">跟进人员</label>
                    <label class="col-sm-1"></label>
                    <div class="col-sm-7" style="padding-top: 7px;">
                        <span class="username">${currentUser.store}</span>
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
                        <span class="username">${currentUser.name}</span>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="margin-top: 0">
                <button type="submit" class="btn blue">提交</button>
                <button type="button" onclick="folowCancel();" class="btn" style="margin-left: 200px;">取消</button>
            </div>
        </form>
    </div>
    <div id="FolowModal" class="modal fade modal-scroll modal-max">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h4 class="modal-title" id="folow-title">查看跟进</h4>
        </div>
        <div class="modal-body" style="min-height: 300px;">
            <div class="table-toolbar">
                <div class="btn-group">
                    <button id="sample_editable_1_new" class="btn green" onclick="createFolow();">
                        <i class="fa fa-plus"></i> 新增跟进
                    </button>
                </div>
            </div>
            <table class="table table-striped table-bordered table-hover" id="FolowTable">
                <thead>
                <tr>
                    <th>跟进时间</th>
                    <th>跟进人员</th>
                    <th>跟进记录</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="FolowBody">
                </tbody>
            </table>
        </div>
    </div>
    <div id="ImgModal" class="modal fade modal-scroll modal-dmax">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h4 class="modal-title" id="img-title"></h4>
        </div>
        <div class="modal-body">
            <img id="detailImg" src="" style="width: 100%;"/>
        </div>
    </div>

    <div class="form-group hide form-line" id="keyTemplate">
        <label class="col-sm-2 control-label">钥匙编号</label>
        <div class="col-sm-3 input-group">
            <input type="text" class="form-control keyList" name="keyList" placeholder="">
        </div >
    </div>
    <div class="form-group hide form-line" id="photoTemplate">
        <label class="col-sm-2 control-label">房屋照片</label>
        <div class="col-sm-3 input-group">
            <input type="hidden" class="imgId">
            <input type="text" class="form-control imgName" placeholder="">
        </div >
        <button type="button" class="col-sm-1 btn blue viewPhotoButton">
            <i class="fa fa-search-plus"></i>
        </button>
        <button type="button" class="col-sm-1 btn btn-default removePhotoButton">
            <i class="fa fa-trash-o"></i>
        </button>
    </div>
    <div id="HouseModal" class="modal fade modal-scroll modal-max">
        <form class="form-horizontal" id="HouseForm" action="javascript:submitHouse();" autocomplete="off" method="post" role="form">
            <div class="modal-header">
                <button type="button" class="close"  aria-hidden="true" onclick="houseCancel();"></button>
                <h4 class="modal-title" id="modal-title"></h4>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <input type="hidden" name="HouseId" id="HouseId"/>
                    <label class="col-sm-12 control-label source-title">房源基础信息</label>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">城区</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" name="cityArea" id="cityArea" placeholder="">
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">片区</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" name="district" id="district" placeholder="">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">楼盘名称</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" name="housesName" id="housesName" placeholder="">
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">期数</label>
                    <div class="col-sm-3">
                        <input type="number" class="form-control" name="periods" id="periods" min="1" placeholder="">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">详细位置</label>
                    <div class="col-sm-1">
                        <input type="number" class="form-control" name="posBuilding" id="posBuilding"  min="1" placeholder="">
                    </div>
                    <label class="control-label" style="float: left;">栋座/位置</label>
                    <div class="col-sm-1">
                        <input type="number" class="form-control" name="posUnit" id="posUnit"  min="1" placeholder="">
                    </div>
                    <label class="control-label" style="float: left;">单元</label>
                    <div class="col-sm-1">
                        <input type="number" class="form-control" name="posFloor" id="posFloor"  min="1" placeholder="">
                    </div>
                    <label class="control-label" style="float: left;">楼层</label>
                    <div class="col-sm-1">
                        <input type="number" class="form-control" name="posRoomNo" id="posRoomNo"  min="1" placeholder="">
                    </div>
                    <label class="control-label" style="float: left;">房号&nbsp;&nbsp;&nbsp;&nbsp;共</label>
                    <div class="col-sm-1">
                        <input type="number" class="form-control" name="posFloorTotal" id="posFloorTotal"  min="1" placeholder="">
                    </div>
                    <label class="control-label" style="float: left;">层</label>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">房型信息</label>
                    <div class="col-sm-1">
                        <input type="number" class="form-control" name="houseRomNum" id="houseRomNum"  min="0" placeholder="">
                    </div>
                    <label class="control-label" style="float: left;">房</label>
                    <div class="col-sm-1">
                        <input type="number" class="form-control" name="houseHallNum" id="houseHallNum" min="0" placeholder="">
                    </div>
                    <label class="control-label" style="float: left;">厅</label>
                    <div class="col-sm-1">
                        <input type="number" class="form-control" name="houseToiletNum" id="houseToiletNum" min="0" placeholder="">
                    </div>
                    <label class="control-label" style="float: left;">卫</label>
                    <div class="col-sm-1">
                        <input type="number" class="form-control" name="houseBalconyNum" id="houseBalconyNum" min="0" placeholder="">
                    </div>
                    <label class="control-label" style="float: left;">阳</label>
                    <div class="col-sm-1">
                        <input type="number" class="form-control" name="houseCarPlace" id="houseCarPlace" min="0" placeholder="">
                    </div>
                    <label class="control-label" style="float: left;">车位</label>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">面积</label>
                    <div class="col-sm-3 input-icon right">
                        <i style="font-style: normal;">㎡</i>
                        <input type="text" class="form-control" name="houseArea" id="houseArea" placeholder="" style="width: 90%;">
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">朝向</label>
                    <div class="col-sm-3">
                        <select class="form-control" id="orientations" name="orientations" >
                            <option value=""></option>
                            <option value="1">朝东</option>
                            <option value="2">朝南</option>
                            <option value="3">朝西</option>
                            <option value="4">朝北</option>
                            <option value="5">南北</option>
                            <option value="6">东西</option>
                            <option value="7">东南</option>
                            <option value="8">西南</option>
                            <option value="9">东北</option>
                            <option value="10">西北</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">用途</label>
                    <div class="col-sm-3">
                        <select class="form-control" id="houseUsage" name="houseUsage" >
                            <option value=""></option>
                            <option value="1">租赁</option>
                            <option value="2">买卖</option>
                            <option value="3">车位</option>
                            <option value="4">商业</option>
                            <option value="5">写字楼</option>
                        </select>
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">装修</label>
                    <div class="col-sm-3">
                        <select class="form-control" id="decoration" name="decoration" >
                            <option value=""></option>
                            <option value="1">毛胚</option>
                            <option value="2">经济型</option>
                            <option value="3">中档型</option>
                            <option value="4">高档型</option>
                            <option value="5">豪华型</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-3 radio-list" id="buildingTypeDiv">
                        <label class="radio-inline">
                            <input type="radio" name="buildingType" id="" value="1"> 笋盘
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="buildingType" id="" value="2"> 锁盘
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-12 control-label source-title" >房源租售信息</label>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">租房管理员：</label>
                    <div class="col-sm-2">
                        <input type="text" class="form-control" name="rentManagerName" id="rentManagerName" placeholder="管理员姓名">
                    </div>
                    <div class="col-sm-3">
                        <select class="form-control select2" name="rentManagerShop" id="rentManagerShop" onchange="rentManagerShopChange();">
                            <option value="">所属门店</option>
                            <optgroup label="河南省郑州市">
                                <option value="1">森林湖店</option>
                                <option value="2">新都汇店</option>
                                <option value="3">湾景国际店</option>
                                <option value="4">悦澜店</option>
                            </optgroup>
                            <optgroup label="湖北省武汉市">
                                <option value="5">森林湖店</option>
                                <option value="6">都汇华府店</option>
                            </optgroup>
                            <optgroup label="安徽省合肥市">
                                <option value="7">都汇华府店</option>
                                <option value="8">都汇华郡店</option>
                                <option value="9">城邦花园店</option>
                            </optgroup>
                        </select>
                    </div>
                    <div class="col-sm-3">
                        <select class="form-control" id="rentStatus" name="rentStatus" >
                            <option value="">租状态</option>
                            <option value="0">可租</option>
                            <option value="1">已租</option>
                            <option value="2">暂缓</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">售房管理员：</label>
                    <div class="col-sm-2">
                        <input type="text" class="form-control" name="sellManagerName" id="sellManagerName" placeholder="管理员姓名">
                    </div>
                    <div class="col-sm-3">
                        <select class="form-control select2" name="sellManagerShop" id="sellManagerShop" onchange="sellManagerShopChange();">
                            <option value="">所属门店</option>
                            <optgroup label="河南省郑州市">
                                <option value="1">森林湖店</option>
                                <option value="2">新都汇店</option>
                                <option value="3">湾景国际店</option>
                                <option value="4">悦澜店</option>
                            </optgroup>
                            <optgroup label="湖北省武汉市">
                                <option value="5">森林湖店</option>
                                <option value="6">都汇华府店</option>
                            </optgroup>
                            <optgroup label="安徽省合肥市">
                                <option value="7">都汇华府店</option>
                                <option value="8">都汇华郡店</option>
                                <option value="9">城邦花园店</option>
                            </optgroup>
                        </select>
                    </div>
                    <div class="col-sm-3">
                        <select class="form-control" id="sellStatus" name="sellStatus" >
                            <option value="">售状态</option>
                            <option value="0">可售</option>
                            <option value="1">已售</option>
                            <option value="2">暂缓</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">租价</label>
                    <div class="col-sm-3 input-icon right">
                        <i style="width: 20%;font-style: normal;">元/月</i>
                        <input type="text" class="form-control" name="rentPrice" id="rentPrice" placeholder="" style="width: 80%;">
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">登记价格</label>
                    <div class="col-sm-3 input-icon right">
                        <i style="width: 20%;font-style: normal;">万</i>
                        <input type="text" class="form-control" name="registerPrice" id="registerPrice" placeholder="" style="width: 80%;">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">售价</label>
                    <div class="col-sm-3 input-icon right">
                        <i style="width: 20%;font-style: normal;">万元</i>
                        <input type="text" class="form-control" name="sellPrice" id="sellPrice" placeholder="" style="width: 80%;">
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">底价</label>
                    <div class="col-sm-3 input-icon right">
                        <i style="width: 20%;font-style: normal;">万</i>
                        <input type="text" class="form-control" name="minPirce" id="minPirce" placeholder="" style="width: 80%;">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">建筑年代</label>
                    <div class="col-sm-3 input-icon right">
                        <i style="width: 20%;font-style: normal;">年</i>
                        <input type="number" class="form-control" name="buildingAge" min="0" id="buildingAge" placeholder="" style="width: 80%;">
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">来源</label>
                    <div class="col-sm-3 ">
                        <input type="text" class="form-control" name="source" id="source" placeholder="" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">到期时间</label>
                    <div class="col-sm-3">
                        <div class="input-group date date-picker" data-date-format="yyyy-mm-dd" data-date-start-date="+0d">
                            <input type="text" class="form-control" name="deadTime" id="deadTime"/>
												<span class="input-group-btn">
												<button class="btn default" type="button"><i class="fa fa-calendar"></i></button>
												</span>
                        </div>
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">责任部门</label>
                    <div class="col-sm-2">
                        <select class="form-control select2" name="dutyShop" id="dutyShop" onchange="dutyShopChange();">
                            <option value="">所属门店</option>
                            <optgroup label="河南省郑州市">
                                <option value="1">森林湖店</option>
                                <option value="2">新都汇店</option>
                                <option value="3">湾景国际店</option>
                                <option value="4">悦澜店</option>
                            </optgroup>
                            <optgroup label="湖北省武汉市">
                                <option value="5">森林湖店</option>
                                <option value="6">都汇华府店</option>
                            </optgroup>
                            <optgroup label="安徽省合肥市">
                                <option value="7">都汇华府店</option>
                                <option value="8">都汇华郡店</option>
                                <option value="9">城邦花园店</option>
                            </optgroup>
                        </select>
                    </div>
                    <div class="col-sm-1">
                        <input type="text" class="form-control" name="dutyStaff" id="dutyStaff" style="text-align: center;" placeholder="员工">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">登记时间</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" name="created" id="created" readonly>
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">委托时间</label>
                    <div class="col-sm-3">
                        <div class="input-group date date-picker" data-date-format="yyyy-mm-dd" data-date-end-date="+0d" style="vertical-align: top;">
                            <input type="text" class="form-control" name="entrustTime" id="entrustTime" onchange="entrustTimeChange();"/>
												<span class="input-group-btn">
												<button class="btn default" type="button"><i class="fa fa-calendar"></i></button>
												</span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">更新时间</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" name="updated" id="updated" readonly>
                        <#--<input class="form-control date-picker" data-date-format="yyyy-mm-dd" type="text" name="updated" id="updated"/>-->
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">客户类别</label>
                    <div class="col-sm-3">
                        <select class="form-control" id="customerType" name="customerType" >
                            <option value=""></option>
                            <option value="1">优质</option>
                            <option value="2">潜在</option>
                            <option value="3">一般</option>
                            <option value="4">游客</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">转介</label>
                    <div class="col-sm-2 ">
                        <input type="text" class="form-control" name="referral1" id="referral1" placeholder="" >
                    </div>
                    <div class="col-sm-2 ">
                        <input type="text" class="form-control" name="referral2" id="referral2" placeholder="" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1"></label>
                    <div class="col-sm-2">
                        <button type="button" class="btn blue form-control addKeyButton"><i class="fa fa-plus"></i> 添加钥匙</button>
                    </div>
                    <label id="keyNotice" class="control-label" style="text-align: left;color:red;display: none;">点击添加钥匙</label>
                </div>
                <div id="keyDiv">

                </div>
                <div class="form-group">
                    <label class="col-sm-1"></label>
                    <div class="col-sm-2" id="upload">
                        <#--<button type="button" id="upload" class="btn btn-xs blue form-control addPhotoButton"><i class="fa fa-plus"></i> 添加房屋照片</button>-->
                    </div>
                </div>
                <div id="photoDiv">

                </div>
                <div class="form-group" style="margin-top: 60px;">
                    <label class="col-sm-2 control-label">备注</label>
                    <div class="col-sm-9">
                        <textarea class="form-control remark" rows="3" id="remark" name="remark" placeholder="1、出租房填写配置的具体家电、家具、若委托租售中心的必须注明；
2、出售房屋填写产权证办理、大产权等情况、共有情况、贷款银行、金额、年限相关情况；" ></textarea>
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-sm-12 control-label source-title">房源产权信息</label>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">产权证号</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" name="propertyCerNo" id="propertyCerNo" placeholder="">
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">登记字号</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" name="registerNo" id="registerNo" placeholder="">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">产证年限</label>
                    <div class="col-sm-3 ">
                        <input type="text" class="form-control" name="propertyCerYear" id="propertyCerYear" placeholder="" >
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">房贷余额</label>
                    <div class="col-sm-3 input-icon right">
                        <i style="width: 20%;font-style: normal;">万</i>
                        <input type="text" class="form-control" name="houseLoanBalance" id="houseLoanBalance" placeholder="" style="width: 80%;">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">产权人</label>
                    <div class="col-sm-2">
                        <input type="text" class="form-control" name="propertyOwnerName" id="propertyOwnerName" placeholder="" >
                    </div>
                    <div class="col-sm-1">
                        <input type="text" class="form-control" name="propertyOwnerShort" id="propertyOwnerShort" style="text-align: center;" placeholder="称呼" >
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">籍贯</label>
                    <div class="col-sm-3 ">
                        <input type="text" class="form-control" name="nativePlace" id="nativePlace" placeholder="" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">身份证号</label>
                    <div class="col-sm-3 ">
                        <input type="text" class="form-control" name="ownerCerNo" id="ownerCerNo" placeholder="" >
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">联系方式</label>
                    <div class="col-sm-3 ">
                        <input type="text" class="form-control" name="ownerLinkPhoneNum" id="ownerLinkPhoneNum" placeholder="" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">QQ</label>
                    <div class="col-sm-3 ">
                        <input type="text" class="form-control" name="ownerQq" id="ownerQq" placeholder="" >
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">传真</label>
                    <div class="col-sm-3 ">
                        <input type="text" class="form-control" name="ownerFax" id="ownerFax" placeholder="" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">邮箱</label>
                    <div class="col-sm-3 ">
                        <input type="email" class="form-control" name="ownerMail" id="ownerMail" onblur="ownerMailBlur();" placeholder="" >
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">业主生日</label>
                    <div class="col-sm-3 ">
                        <input type="text" class="form-control" name="ownerBirth" id="ownerBirth" placeholder="" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">备注</label>
                    <div class="col-sm-9">
                        <textarea class="form-control" rows="3" id="propertyRemark" name="propertyRemark" placeholder="记录产权人的相关信息，例如：家庭状况、业主特点、业主要求；" ></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">产权代理人</label>
                    <div class="col-sm-2">
                        <input type="text" class="form-control" name="agentName" id="agentName" placeholder="" >
                    </div>
                    <div class="col-sm-1">
                        <input type="text" class="form-control" name="agentShort" id="agentShort" style="text-align: center;" placeholder="称呼" >
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">籍贯</label>
                    <div class="col-sm-3 ">
                        <input type="text" class="form-control" name="agentNativePlace" id="agentNativePlace" placeholder="" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">身份证号</label>
                    <div class="col-sm-3 ">
                        <input type="text" class="form-control" name="agentCerNo" id="agentCerNo" placeholder="" >
                    </div>
                    <label class="col-sm-1"></label>
                    <label class="col-sm-2 control-label">联系方式</label>
                    <div class="col-sm-3 ">
                        <input type="text" class="form-control" name="agentLinkPhoneNum" id="agentLinkPhoneNum" placeholder="" >
                    </div>
                </div>




            </div>
            <div class="modal-footer">
                <button type="submit" class="btn blue">提交</button>
                <button type="button" class="btn" style="margin-left: 200px;" onclick="houseCancel();">取消</button>
            </div>
        </form>
    </div>
    <!-- BEGIN PAGE CONTENT-->
    <div class="row">
        <div class="col-md-12">
            <div class="table-toolbar">
                <div class="btn-group">
                    <button id="sample_editable_1_new" class="btn green" onclick="createHouse();">
                        <i class="fa fa-plus"></i> 录入新房源
                    </button>
                </div>
            </div>
        </div>
        <div class="col-md-12">
            <div class="portlet box light-grey">
                <div class="portlet-title">
                    <div class="caption"><i class="fa fa-search"></i> 筛选</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-md-1 control-label">面积：</label>

                            <div class="col-md-10 searchAreaDiv">
                                <div class="btn-group" data-toggle="buttons">
                                    <label class="btn blue active">
                                        <input type="radio" name="searchArea" class="toggle" value=""> 不限
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchArea" class="toggle" value="0-30"> 30㎡以下
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchArea" class="toggle" value="30-50"> 30-50㎡
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchArea" class="toggle" value="70-90"> 70-90㎡
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchArea" class="toggle" value="90-120"> 90-120㎡
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchArea" class="toggle" value="120-">120㎡以上
                                    </label>
                                    <label class="btn searchAreaRange">
                                        <input type="number" min="0" style="width: 60px;" id="searchMinArea" class="toggle" onblur="search();" value=""/> - <input type="number" min="0" style="width: 60px;" id="searchMaxArea" class="toggle" onblur="search();" value=""/>
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-1 control-label">房型：</label>
                            <div class="col-md-10">
                                <div class="btn-group" data-toggle="buttons">
                                    <label class="btn blue active">
                                        <input type="radio" name="searchHouseRomNum" class="toggle" value=""> 不限
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchHouseRomNum" class="toggle" value="1"> 一室
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchHouseRomNum" class="toggle" value="2"> 二室
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchHouseRomNum" class="toggle" value="3"> 三室
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchHouseRomNum" class="toggle" value="4"> 四室
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchHouseRomNum" class="toggle" value="5"> 五室
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchHouseRomNum" class="toggle" value="6"> 五室以上
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-1 control-label">用途：</label>
                            <div class="col-md-10">
                                <div class="btn-group" data-toggle="buttons">
                                    <label class="btn blue active">
                                        <input type="radio" name="searchUsage" class="toggle" value=""> 不限
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchUsage" class="toggle" value="1"> 租赁
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchUsage" class="toggle" value="2"> 买卖
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchUsage" class="toggle" value="3"> 车位
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchUsage" class="toggle" value="4"> 商业
                                    </label>
                                    <label class="btn blue">
                                        <input type="radio" name="searchUsage" class="toggle" value="5"> 写字楼
                                    </label>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-12">
            <!-- BEGIN EXAMPLE TABLE PORTLET-->
            <div class="portlet box light-grey">
                <div class="portlet-title">
                    <div class="caption"><i class="fa fa-globe"></i>房源列表</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <table class="table table-striped table-bordered table-hover" id="HouseTable">
                        <thead>
                        <tr>
                            <th>房源编号</th>
                            <th>地理位置</th>
                            <th>小区名称</th>
                            <th>户型</th>
                            <th>面积</th>
                            <th>所属门店</th>
                            <th>租状态</th>
                            <th>售状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="HouseBody">
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- END EXAMPLE TABLE PORTLET-->
        </div>
    </div>
    <!-- END PAGE CONTENT-->
</div>
<!-- END PAGE -->
<#include "/common/footer.ftl">

<script type="text/javascript" src="${basePath}/plugins/bootstrap-modal/js/bootstrap-modal.js"></script>
<script type="text/javascript" src="${basePath}/plugins/bootstrap-modal/js/bootstrap-modalmanager.js"></script>
<link rel="stylesheet" type="text/css" href="${basePath}/plugins/bootstrap-datepicker/css/datepicker.css" />
<script type="text/javascript" src="${basePath}/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>


<link rel="stylesheet" type="text/css" href="${basePath}/plugins/Huploadify/Huploadify.css" />
<script type="text/javascript" src="${basePath}/plugins/Huploadify/jquery.Huploadify.js"></script>

<script src="${basePath}/plugins/layer/layer.js"></script>
<link href="${basePath}/plugins/layer/skin/layer.css" rel="stylesheet">
<link href="${basePath}/css/pages/house.css" rel="stylesheet">
<script src="${basePath}/plugins/jquery.watermark.js"></script>
<script src="${basePath}/scripts/house.js"></script>
<script src="${basePath}/scripts/common.js"></script>

<script>

    var ViewHouse="";
    var ViewHouseSource;
    var HouseSource;
    var ifLastIsModify=false;
    var ifSearchAreaRange=false;
    var ifDataAll='${ifDataAll}';
    var currentUserId='${currentUser.id}';


    jQuery(document).ready(function() {
        $('.select2').select2({
            allowClear: true
        });

        search();
        $('.searchAreaDiv').on('click', 'label', function() {
            var className = $(this)[0].className;
            if(className.indexOf("searchAreaRange")>=0){
                ifSearchAreaRange=true;
                $('.searchAreaDiv').find(".btn").removeClass("active");
                $(this).addClass("choosed");
                var areaMin=$("#searchMinArea").val();
                var areaMax=$("#searchMaxArea").val();
                if(ifNotNull(areaMin) || ifNotNull(areaMax) ){
                    search();
                }
            }else{
                ifSearchAreaRange=false;
                $('.searchAreaDiv').find(".searchAreaRange").removeClass("choosed");
            }
        });

        $('input:radio[name="searchArea"]').change( function(e){
            var lab=$(this);
            lab[0].checked=true;
            search();
        });
        $('input:radio[name="searchHouseRomNum"]').change( function(e){
            var lab=$(this);
            lab[0].checked=true;
            search();
        });
        $('input:radio[name="searchUsage"]').change( function(e){
            var lab=$(this);
            lab[0].checked=true;
            search();
        });
        House.init();

        $('#HouseBody').on('click', '.viewFolow', function() {
            var $tr = $(this).parents('tr');
            var id=$tr[0].id;
            $("#houseId").val(id);
            ViewHouse=id;
            loadFolowTable();
        });

        $('#HouseBody').on('click', '.viewHouse', function() {
            var $tr = $(this).parents('tr');
            var id=$tr[0].id;
            $("#houseId").val(id);
            ViewHouse=id;
            viewHouseDetail();
        });

        $('#FolowBody').on('click', '.deleteFolow', function() {
            var $tr = $(this).parents('tr');
            var id=$tr[0].id;
            var data={};
            data.folowIds=id;
            layer.confirm('是否删除该跟进信息?', {
                title:" ",
                btn: ['是','否'] //按钮
            }, function(){
                var url=FolowDeleteURL;
                $.ajax({
                    async: false,
                    url: url,
                    dataType: 'jsonp',
                    type: 'GET',
                    jsonp: 'callback',
                    data: data,
                    success: function (json) {
                        var result=verifyResult(json);
                        if(result) {
                            loadFolowTable();
                        }
                    }
                })
                layer.msg('删除成功', {
                    time: 1000, //1s后自动关闭
                });
            }, function(){
            });
        });

    });

    function sellManagerShopChange(){
        var sellManagerShop=$("#sellManagerShop");
        sellManagerShop.parent().removeClass('has-error');
        sellManagerShop.parent().find(".help-block").remove();
    }
    function rentManagerShopChange(){
        var rentManagerShop=$("#rentManagerShop");
        rentManagerShop.parent().removeClass('has-error');
        rentManagerShop.parent().find(".help-block").remove();
    }
    function dutyShopChange(){
        var dutyShop=$("#dutyShop");
        dutyShop.parent().removeClass('has-error');
        dutyShop.parent().find(".help-block").remove();
    }
    function entrustTimeChange(){
        var entrustTime=$("#entrustTime");
        entrustTime.parent().removeClass('has-error');
        entrustTime.parent().find(".help-block").remove();
    }
    function ownerMailBlur(){
        var ownerMail=$("#ownerMail");
        if(ifNotNull(ownerMail.val())){

        }else{
            ownerMail.parent().removeClass('has-error');
            ownerMail.parent().find(".help-block").remove();
        }
    }


    function getNowDateStr(){
        var now=new Date();
        var year = now.getFullYear();
        var month =(now.getMonth() + 1).toString();
        var day = (now.getDate()).toString();
        var hour = (now.getHours()).toString();
        var minute = (now.getMinutes()).toString();
        var second = (now.getSeconds()).toString();
        if (month.length == 1) {
            month = "0" + month;
        }
        if (day.length == 1) {
            day = "0" + day;
        }
        var dateTime = year + "-" + month + "-" + day;
        return dateTime;
    }
    function createHouse(){
        $("#modal-title").html("新房源录入");
        keyNum=0;
        photoNum=0;
        $('#keyDiv').html("");
        $('#photoDiv').html("");
        $('#HouseId').val("");
        $("#rentManagerShop").select2("val", "");
        $("#sellManagerShop").select2("val", "");
        $("#dutyShop").select2("val", "");
        $("input[name='keyList']").val("");
            $("#HouseForm")[0].reset();
            $('#HouseForm').validate().resetForm();
            $("#HouseForm").find("div").removeClass("has-error");
        var text='<label class="radio-inline">'
                +'<input type="radio" name="buildingType" id="" value="1"> 笋盘'
                +'</label>'
                +'<label class="radio-inline">'
                +'<input type="radio" name="buildingType" id="" value="2"> 锁盘'
                +'</label>';
        $('#buildingTypeDiv').html(text);

        $("#created").val(getNowDateStr());
        $("#updated").val(getNowDateStr());
        $('#HouseModal').modal({backdrop:"static",show:true});
    }
    function houseCancel(){
        layer.confirm('是否关闭当前窗口?</br>（若是，当前更改的信息将不会保存！）', {
            title:" ",
            btn: ['是','否'] //按钮
        }, function(){
            $("#HouseModal").modal('hide');
            var index = layer.index; //获取当前弹层的索引号
            layer.close(index); //关闭当前弹层
        }, function(){
        });
    }
    function folowCancel(){
        layer.confirm('是否关闭当前窗口?</br>（若是，当前更改的信息将不会保存！）', {
            title:" ",
            btn: ['是','否'] //按钮
        }, function(){
            $("#FolowAddModal").modal('hide');
            var index = layer.index; //获取当前弹层的索引号
            layer.close(index); //关闭当前弹层
        }, function(){
        });
    }

    function createFolow(){
        $("#folowContent").val("");
        $("#FolowAddModal").modal('show');
    }

    if (jQuery().datepicker) {
        $('.date-picker').datepicker({
            rtl: App.isRTL(),
            autoclose: true
        });
    }

    function search(){
        var data={};
        if(ifSearchAreaRange){
            var areaMin=$("#searchMinArea").val();
            var areaMax=$("#searchMaxArea").val();
            if(ifNotNull(areaMin) && ifNotNull(areaMax) && (parseInt(areaMin)>parseInt(areaMax))){
                $("#searchMinArea").val(areaMax);
                $("#searchMaxArea").val(areaMin);
                data.areaMin=areaMax;
                data.areaMax=areaMin;
//                layer.alert("面积参数错误！开始值不能大于结束值！");
//                return;
            }else{
                data.areaMin=areaMin;
                data.areaMax=areaMax;
            }
        }else{
            var searchArea=$('input:radio[name="searchArea"]:checked').val();
            if(searchArea&&searchArea!=""&&searchArea.length>0){
                var areaMin,areaMax;
                var index=searchArea.indexOf("-");
                areaMin=searchArea.substring(0,index);
                areaMax=searchArea.substring(index+1,searchArea.length);
                data.areaMin=areaMin;
                data.areaMax=areaMax;
            }
        }
        var searchHouseRomNum=$('input:radio[name="searchHouseRomNum"]:checked').val();
        if(searchHouseRomNum&&searchHouseRomNum!=""&&searchHouseRomNum.length>0){
            data.houseRomNum=searchHouseRomNum;
        }
        var searchUsage=$('input:radio[name="searchUsage"]:checked').val();
        if(searchUsage&&searchUsage!=""&&searchUsage.length>0){
            data.usage=searchUsage;
        }
        data.page=1;
        data.rows=1000;
        var url=HouseListURL;
        $.ajax({
            async: false,
            url: url,
            dataType: 'jsonp',
            type: 'GET',
            jsonp: 'callback',
            data: data,
            success: function (json) {
                var result=verifyResult(json);
                if(result) {
                    $('#HouseTable').dataTable().fnClearTable();
                    $('#HouseTable').dataTable().fnDestroy();
                    var list = json.attach.list;
                    var text = "";
                    for (var i = 0; i < list.length; i++) {
                        var house = list[i];
                        text += "<tr id='" + house.id + "'><td>" + house.id + "</td><td>" + house.district + "</td><td>" + house.housesName + " " + house.periods + "期" + "</td><td>" + getHouseType(house)
                                + "</td><td>" + house.houseArea + "</td><td>" + house.storeCity + house.storeName + "</td>"
                                + "<td>" + getRentStatusStr(house.rentStatus) + "</td><td>" + getSellStatusStr(house.sellStatus) + "</td><td>"
                                + " <a href='javascript:void(0);' class='btn blue btn-xs viewFolow'><i class='fa fa-eye'></i> 查看跟进</a>&nbsp;&nbsp;"
                                + "<a href='javascript:void(0);' class='btn green btn-xs viewHouse'><i class='fa fa-edit'></i> 查看详情</a>"
                                + "</td></tr>";
                    }
                    $("#HouseBody").html(text);
                    if (!jQuery().dataTable) {
                        return;
                    }

                    // begin first table
                    $('#HouseTable').dataTable({
                        "aoColumns": [
                            null,
                            {"bSortable": false},
                            {"bSortable": false},
                            {"bSortable": false},
                            {"bSortable": false},
                            {"bSortable": false},
                            {"bSortable": false},
                            {"bSortable": false},
                            {"bSortable": false}
                        ],
                        "aLengthMenu": [
                            [5, 15, 20, -1],
                            [5, 15, 20, "All"] // change per page values here
                        ],
                        // set the initial value
                        "aaSorting": [[0, "desc"]],
                        "iDisplayLength": 20,
                        "sPaginationType": "bootstrap"
                    });

                    $("#HouseTable_filter").hide();
                    $("#HouseTable_length").hide();
                }
            }
        })
    }
    function ifNotNull(value){
        if (value == null || value == undefined || value == '') {
            return false;
        }else{
            return true;
        }
    }
    function getHouseType(house){
        var type="";
        if(ifNotNull(house.houseRomNum)){
            type+=house.houseRomNum+"房";
        }
        if(ifNotNull(house.houseHallNum)){
            type+=house.houseHallNum+"厅";
        }
        if(ifNotNull(house.houseToiletNum)){
            type+=house.houseToiletNum+"卫";
        }
        if(ifNotNull(house.houseBalconyNum)){
            type+=house.houseBalconyNum+"阳台";
        }
        if(ifNotNull(house.houseCarPlace)){
            type+=house.houseCarPlace+"车位";
        }
        return type;
    }

    function loadFolowTable(){
        $('#FolowTable').dataTable().fnClearTable();
        $('#FolowTable').dataTable().fnDestroy();
        var data={};
        data.houseId=ViewHouse;
        data.page=1;
        data.rows=1000;
        var url=FolowListURL;
        $.ajax({
            async: false,
            url: url,
            dataType: 'jsonp',
            type: 'GET',
            jsonp: 'callback',
            data: data,
            success: function (json) {
                var result=verifyResult(json);
                if(result) {
                    var list = json.attach.list;
                    var text = "";
                    for (var i = 0; i < list.length; i++) {
                        var folow = list[i];
                        var deleteBtnText = " <a href='javascript:void(0);' class='btn default btn-xs deleteFolow'><i class='fa fa-trash-o'></i> 删除跟进</a>";
                        text += "<tr id='" + folow.id + "'><td>" + folow.createTime + "</td><td>" + folow.userName + "</td><td style='width:600px;white-space: pre-wrap; '>" + folow.folowContent + "</td><td>";
                        if (parseInt(ifDataAll) == 1) {
                            text += deleteBtnText;
                        }
                        text += "</td></tr>";
                    }
                    $("#FolowBody").html(text);


                    if (!jQuery().dataTable) {
                        return;
                    }

                    // begin first table
                    $('#FolowTable').dataTable({
                        "aoColumns": [
                            null,
                            {"bSortable": false},
                            {"bSortable": false},
                            {"bSortable": false}
                        ],
                        "aLengthMenu": [
                            [5, 15, 20, -1],
                            [5, 15, 20, "All"] // change per page values here
                        ],
                        // set the initial value
                        "aaSorting": [[0, "desc"]],
                        "iDisplayLength": 20,
                        "sPaginationType": "bootstrap"
                    });

                    $("#FolowTable_filter").hide();
                    $("#FolowTable_length").hide();
                    $("#FolowModal").modal('show');
                }
            }
        })
    }

    function viewHouseDetail(){
        var data={};
        data.id=ViewHouse;
        var url=HouseViewURL;
        $.ajax({
            async: false,
            url: url,
            dataType: 'jsonp',
            type: 'GET',
            jsonp: 'callback',
            data: data,
            success: function (json) {
                var result=verifyResult(json);
                if(result){
                    var attach=json.attach;
                    if(parseInt(ifDataAll)==1){
                        $('#HouseEditBtn').show();
                        $('#HouseDeleteBtn').show();
                    }else{
                        var userId=attach.basic.userId;
                        if(userId==currentUserId){
                            $('#HouseEditBtn').show();
                        }else{
                            $('#HouseEditBtn').hide();
                        }
                        $('#HouseDeleteBtn').hide();
                    }
                    ViewHouseSource=attach;
                    var basic=attach.basic;
                    $('#cityAreaV').html(basic.cityArea);
                    $('#districtV').html(basic.district);
                    $('#housesNameV').html(basic.housesName);
                    $('#periodsV').html(basic.periods);
                    $('#posBuildingV').html(basic.posBuilding);
                    $('#posUnitV').html(basic.posUnit);
                    $('#posFloorV').html(basic.posFloor);
                    $('#posRoomNoV').html(basic.posRoomNo);
                    $('#posFloorTotalV').html(basic.posFloorTotal);
                    $('#houseRomNumV').html(basic.houseRomNum);
                    $('#houseHallNumV').html(basic.houseHallNum);
                    $('#houseToiletNumV').html(basic.houseToiletNum);
                    $('#houseBalconyNumV').html(basic.houseBalconyNum);
                    $('#houseCarPlaceV').html(basic.houseCarPlace);
                    $('#houseAreaV').html(basic.houseArea);
                    var orientations=basic.orientations;
                    var orientationsStr="";
                    if(orientations==1){
                        orientationsStr="朝东"
                    }else if(orientations==2){
                        orientationsStr="朝南"
                    }else if(orientations==3){
                        orientationsStr="朝西"
                    }else if(orientations==4){
                        orientationsStr="朝北"
                    }else if(orientations==5){
                        orientationsStr="南北"
                    }else if(orientations==6){
                        orientationsStr="东西"
                    }else if(orientations==7){
                        orientationsStr="东南"
                    }else if(orientations==8){
                        orientationsStr="西南"
                    }else if(orientations==9){
                        orientationsStr="东北"
                    }else if(orientations==9){
                        orientationsStr="西北"
                    }
                    $('#orientationsV').html(orientationsStr);
                    var houseUsage=basic.houseUsage;
                    var houseUsageStr="";
                    if(houseUsage==1){
                        houseUsageStr="租赁"
                    }else if(houseUsage==2){
                        houseUsageStr="买卖"
                    }else if(houseUsage==3){
                        houseUsageStr="车位"
                    }else if(houseUsage==4){
                        houseUsageStr="商业"
                    }else if(houseUsage==5){
                        houseUsageStr="写字楼"
                    }
                    $('#houseUsageV').html(houseUsageStr);
                    $('#buildingTypeV').html(basic.buildingType);
                    var decoration=basic.decoration;
                    var decorationStr="";
                    if(decoration==1){
                        decorationStr="毛胚"
                    }else if(orientations==2){
                        decorationStr="经济型"
                    }else if(orientations==3){
                        decorationStr="中档型"
                    }else if(orientations==4){
                        decorationStr="高档型"
                    }else if(orientations==5){
                        decorationStr="豪华型"
                    }
                    $('#decorationV').html(decorationStr);
                    var buildingType=basic.buildingType;
                    var buildingTypeText="";
                    if(buildingType==1){
                        buildingTypeText='<label class="radio-inline">'
                                + '<input type="radio" name="buildingTypeV" id="" value="1" checked readonly disabled> 笋盘'
                                + '</label>'
                                + '<label class="radio-inline">'
                                + '<input type="radio" name="buildingTypeV" id="" value="2" readonly disabled> 锁盘'
                                + '</label>';
                    }else if(buildingType==2){
                        buildingTypeText='<label class="radio-inline">'
                                + '<input type="radio" name="buildingTypeV" id="" value="1" readonly disabled> 笋盘'
                                + '</label>'
                                + '<label class="radio-inline">'
                                + '<input type="radio" name="buildingTypeV" id="" value="2" checked readonly disabled> 锁盘'
                                + '</label>';
                    }else{
                        buildingTypeText='<label class="radio-inline">'
                                + '<input type="radio" name="buildingTypeV" id="" value="1" readonly disabled> 笋盘'
                                + '</label>'
                                + '<label class="radio-inline">'
                                + '<input type="radio" name="buildingTypeV" id="" value="2" readonly disabled> 锁盘'
                                + '</label>';

                    }
                    $('#buildingTypeVDiv').html(buildingTypeText);

                    var rent=attach.rent;
                    $('#rentManagerNameV').html(rent.rentManagerName);
                    $('#sellManagerNameV').html(rent.sellManagerName);
                    $('#rentManagerShopV').html(getStoreName(rent.rentManagerShop));
                    $('#sellManagerShopV').html(getStoreName(rent.sellManagerShop));
                    var rentStatus=rent.rentStatus;
                    var rentStatusStr="";
                    if(rentStatus==0){
                        rentStatusStr="可租"
                    }else if(rentStatus==1){
                        rentStatusStr="已租"
                    }else if(rentStatus==2){
                        rentStatusStr="暂缓"
                    }
                    $('#rentStatusV').html(rentStatusStr);
                    var sellStatus=rent.sellStatus;
                    var sellStatusStr="";
                    if(sellStatus==0){
                        sellStatusStr="可售"
                    }else if(sellStatus==1){
                        sellStatusStr="已售"
                    }else if(sellStatus==2){
                        sellStatusStr="暂缓"
                    }
                    $('#sellStatusV').html(sellStatusStr);

                    $('#rentPriceV').html(rent.rentPrice);
                    $('#sellPriceV').html(rent.sellPrice);
                    $('#registerPriceV').html(rent.registerPrice);
                    $('#minPirceV').html(rent.minPirce);
                    $('#buildingAgeV').html(rent.buildingAge);
                    $('#sourceV').html(rent.source);
                    $('#deadTimeV').html(rent.deadTime.substring(0,10));
                    $('#dutyShopV').html(getStoreName(rent.dutyShop));
                    $('#dutyStaffV').html(rent.dutyStaff);
                    $('#entrustTimeV').html(rent.entrustTime.substring(0,10));

                    var customerType=rent.customerType;
                    var customerTypeStr="";
                    if(customerType==1){
                        customerTypeStr="优质"
                    }else if(customerType==2){
                        customerTypeStr="潜在"
                    }else if(customerType==3){
                        customerTypeStr="一般"
                    }else if(customerType==4){
                        customerTypeStr="游客"
                    }
                    $('#customerTypeV').html(customerTypeStr);

                    $('#referral1V').html(rent.referral1);
                    $('#referral2V').html(rent.referral2);
                    $('#keyListV').html(rent.keyList);
                    $('#remarkV').html(rent.remark);
                    $('#createTimeV').html(rent.createTime.substring(0,10));
                    $('#modTimeV').html(rent.modTime.substring(0,10));
                    var housePhotoList=rent.housePhotoList;
                    var imgs=JSON.parse(housePhotoList);
                    if(imgs!=null){
                        var imgsText="";
                        for(var i=0;i<imgs.length;i++){
                            var img=imgs[i];
                            imgsText+= '<div class="form-group form-line"><label class="col-sm-2 control-label">房屋照片</label>'
                                    +'<label class="col-sm-3 control-label2">'
                                    +img.name
                                    +'</label >'
                                    +'<button type="button" class="col-sm-1 btn blue viewPhotoButton" id="'+img.id+'">'
                                    +'<i class="fa fa-search-plus"></i> 查看'
                                    +'</button> </div>';
                        }
                        $('#ViewImgs').html(imgsText);
                    }

                    var property=attach.property;
                    $('#propertyCerNoV').html(property.propertyCerNo);
                    $('#registerNoV').html(property.registerNo);
                    $('#propertyCerYearV').html(property.propertyCerYear);
                    $('#houseLoanBalanceV').html(property.houseLoanBalance);
                    $('#propertyOwnerNameV').html(property.propertyOwnerName);
                    $('#propertyOwnerShortV').html(property.propertyOwnerShort);
                    $('#nativePlaceV').html(property.nativePlace);
                    $('#ownerCerNoV').html(property.ownerCerNo);
                    $('#ownerLinkPhoneNumV').html(property.ownerLinkPhoneNum);
                    $('#ownerQqV').html(property.ownerQq);
                    $('#ownerFaxV').html(property.ownerFax);
                    $('#ownerMailV').html(property.ownerMail);
                    $('#ownerBirthV').html(property.ownerBirth);
                    $('#propertyRemarkV').html(property.remark);
                    $('#agentNameV').html(property.agentName);
                    $('#agentShortV').html(property.agentShort);
                    $('#agentNativePlaceV').html(property.agentNativePlace);
                    $('#agentCerNoV').html(property.agentCerNo);
                    $('#agentLinkPhoneNumV').html(property.agentLinkPhoneNum);

                    $('#ViewHouseSourceModal').modal({backdrop:"static",show:true});
                }
            }
        })
    }

    function getStoreName(num){
        var name="";
        if(num==1){
            name="河南省郑州市森林湖店";
        }
        if(num==2){
            name="河南省郑州市新都汇店";
        }
        if(num==3){
            name="河南省郑州市湾景国际店";
        }
        if(num==4){
            name="河南省郑州市悦澜店";
        }
        if(num==5){
            name="湖北省武汉市森林湖店";
        }
        if(num==6){
            name="湖北省武汉市都汇华府店";
        }
        if(num==7){
            name="安徽省合肥市都汇华府店";
        }
        if(num==8){
            name="安徽省合肥市都汇华郡店";
        }
        if(num==9){
            name="安徽省合肥市城邦花园店";
        }
        return name;
    }
    function getRentStatusStr(num){
        var rentStatusStr="";
        if(num==0){
            rentStatusStr="可租"
        }else if(num==1){
            rentStatusStr="已租"
        }else if(num==2){
            rentStatusStr="暂缓"
        }
        return rentStatusStr;
    }
    function getSellStatusStr(num){
        var rentStatusStr="";
        if(num==0){
            rentStatusStr="可售";
        }else if(num==1){
            rentStatusStr="已售";
        }else if(num==2){
            rentStatusStr="暂缓";
        }
        return rentStatusStr;
    }

    function submitFolow(){
        var data={};
        var formData= $('#FolowForm').serializeArray();
        $.each(formData, function() {
            data[this.name] = this.value;
        });
        var url=FolowAddURL;
        $.ajax({
            async: false,
            url: url,
            dataType: 'jsonp',
            type: 'GET',
            jsonp: 'callback',
            data: data,
            success: function (json) {
                var result=verifyResult(json);
                if(result) {
                    loadFolowTable();
                    $("#FolowAddModal").modal('hide');
                }
            }
        })
    }
    
    function submitHouse(){
        var data={};
        var formData= $('#HouseForm').serializeArray();
        var keyList=null;
        $.each(formData, function() {
            data[this.name] = this.value;
            if(this.name=="keyList"){
                keyList=this.value;
            }
        });
        if(ifNotNull(keyList)){

        }else{
            layer.alert("请完善钥匙信息！",{title: " "});
            $("#keyNotice").show();
            return;
        }

        var imgs=$("#photoDiv .imgName");
        var photos=new Array();
        for(var i=0;i<imgs.length;i++){
            var img=imgs[i];
            var thisImg=$(img);
            var $row = $(img).parents('.form-line');
            var id=$row.find(".imgId").val();
            var name=$(img).val();
            var photo={};
            photo.id=id;
            photo.name=name;
            photos.push(photo);
        }
        var housePhotoList=JSON.stringify(photos);
        data.housePhotoList=housePhotoList;

        var tilte="";
        var url="";
        var houseId= $("#HouseId").val();

        if(ifNotNull(houseId)){
            url=HouseEditURL;
            title="确认修改该房源信息？";
            data.houseId=houseId;
        }else{
            url=HouseAddURL;
            title="确认提交新房源信息？";
        }
        layer.confirm(title, {
            title:" ",
            btn: ['是','否'] //按钮
        }, function(){
            $.ajax({
                async: false,
                url: url,
                dataType: 'jsonp',
                type: 'GET',
                jsonp: 'callback',
                data: data,
                success: function (json) {
                    var result=verifyResult(json);
                    if(result){
                        search();
                        $("#HouseModal").modal('hide');
                        if(ifNotNull(houseId)){
                            layer.msg('修改成功', {
                                time: 1000, //1s后自动关闭
                            });
                        }else{
                            layer.msg('添加成功', {
                                time: 1000, //1s后自动关闭
                            });
                        }
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown){
                    layer.alert(XMLHttpRequest.status+XMLHttpRequest.readyState+textStatus,{title: " "});
                }

            })
        }, function(){
        });
    }

    function editHouse(){
        ifLastIsModify=true;
        $("#HouseForm")[0].reset();
        $('#HouseForm').validate().resetForm();
        $("#HouseForm").find("div").removeClass("has-error");
        $("#modal-title").html("修改房源信息");
        var attach=ViewHouseSource; 
        var basic=attach.basic;
        $("#HouseId").val(basic.id);
        $('#cityArea').val(basic.cityArea);
        $('#district').val(basic.district);
        $('#housesName').val(basic.housesName);
        $('#periods').val(basic.periods);
        $('#posBuilding').val(basic.posBuilding);
        $('#posUnit').val(basic.posUnit);
        $('#posFloor').val(basic.posFloor);
        $('#posRoomNo').val(basic.posRoomNo);
        $('#posFloorTotal').val(basic.posFloorTotal);
        $('#houseRomNum').val(basic.houseRomNum);
        $('#houseHallNum').val(basic.houseHallNum);
        $('#houseToiletNum').val(basic.houseToiletNum);
        $('#houseBalconyNum').val(basic.houseBalconyNum);
        $('#houseCarPlace').val(basic.houseCarPlace);
        $('#houseArea').val(basic.houseArea);
        $('#orientations').val(basic.orientations);
        $('#houseUsage').val(basic.houseUsage);

        var buildingType=parseInt(basic.buildingType);
        var text='<label class="radio-inline">'
                +'<input type="radio" name="buildingType" id="" value="1"';
        if(buildingType==1){
            text+=' checked ';
        }
        text+='> 笋盘</label>'
                +'<label class="radio-inline">'
                +'<input type="radio" name="buildingType" id="" value="2"';
        if(buildingType==2){
            text+=' checked ';
        }
        text+='> 锁盘</label>';
        $('#buildingTypeDiv').html(text);
        $('#decoration').val(basic.decoration);

        var rent=attach.rent;
        $('#rentManagerName').val(rent.rentManagerName);
        $('#sellManagerName').val(rent.sellManagerName);;
        $("#rentManagerShop").select2("val", rent.rentManagerShop);
        $("#sellManagerShop").select2("val", rent.sellManagerShop);
//        $('#rentManagerShop').val(rent.rentManagerShop);
//        $('#sellManagerShop').val(rent.sellManagerShop);
        $('#rentStatus').val(rent.rentStatus);
        $('#sellStatus').val(rent.sellStatus);

        $('#rentPrice').val(rent.rentPrice);
        $('#sellPrice').val(rent.sellPrice);
        $('#registerPrice').val(rent.registerPrice);
        $('#minPirce').val(rent.minPirce);
        $('#buildingAge').val(rent.buildingAge);
        $('#source').val(rent.source);
        $('#deadTime').val(rent.deadTime.substring(0,10));
        $("#dutyShop").select2("val", rent.dutyShop);
//        $('#dutyShop').val(rent.dutyShop);
        $('#dutyStaff').val(rent.dutyStaff);
        $('#entrustTime').val(rent.entrustTime.substring(0,10));
        $('#customerType').val(rent.customerType);
        $('#referral1').val(rent.referral1);
        $('#referral2').val(rent.referral2);
        $('#keyList').val(rent.keyList);
        $('#remark').val(rent.remark);
        $('#created').val(rent.createTime.substring(0,10));
        $('#updated').val(rent.modTime.substring(0,10));
        $('#keyDiv').html("");
        var keyList=rent.keyList;
        if(ifNotNull(keyList)){
            var $template = $('#keyTemplate');
            $template.find(".keyList").val(keyList);
            var $clone = $template
                    .clone()
                    .removeClass('hide')
                    .removeAttr('id');
            $('#keyDiv').append($clone);
            keyNum++;
        }
        $('#photoDiv').html("");
        var imgs=JSON.parse(rent.housePhotoList);
        if(imgs!=null){
            for(var i=0;i<imgs.length;i++){
                var img=imgs[i];
                var $template = $('#photoTemplate');
                $template.find(".imgId").val(img.id);
                $template.find(".imgName").val(img.name);
                $template.find(".viewPhotoButton").attr('id',img.id);
                var $clone = $template
                        .clone()
                        .removeClass('hide')
                        .removeAttr('id');
                $('#photoDiv').append($clone);
                photoNum++;
            }
        }

        var property=attach.property;
        $('#propertyCerNo').val(property.propertyCerNo);
        $('#registerNo').val(property.registerNo);
        $('#propertyCerYear').val(property.propertyCerYear);
        $('#houseLoanBalance').val(property.houseLoanBalance);
        $('#propertyOwnerName').val(property.propertyOwnerName);
        $('#propertyOwnerShort').val(property.propertyOwnerShort);
        $('#nativePlace').val(property.nativePlace);
        $('#ownerCerNo').val(property.ownerCerNo);
        $('#ownerLinkPhoneNum').val(property.ownerLinkPhoneNum);
        $('#ownerQq').val(property.ownerQq);
        $('#ownerFax').val(property.ownerFax);
        $('#ownerMail').val(property.ownerMail);
        $('#ownerBirth').val(property.ownerBirth);
        $('#propertyRemark').val(property.remark);
        $('#agentName').val(property.agentName);
        $('#agentShort').val(property.agentShort);
        $('#agentNativePlace').val(property.agentNativePlace);
        $('#agentCerNo').val(property.agentCerNo);
        $('#agentLinkPhoneNum').val(property.agentLinkPhoneNum);
        $("#ViewHouseSourceModal").modal('hide');
//        $("#HouseModal").modal('show');
        $('#HouseModal').modal({backdrop:"static",show:true});
    }
    function deleteHouse(){
        var attach=ViewHouseSource;
        var basic=attach.basic;
        var houseId=basic.id;
        var data={};
        data.id=houseId;
        layer.confirm('是否删除该房源信息?', {
            title:" ",
            btn: ['是','否'] //按钮
        }, function(){
            var url=HouseDeleteURL;
            $.ajax({
                async: false,
                url: url,
                dataType: 'jsonp',
                type: 'GET',
                jsonp: 'callback',
                data: data,
                success: function (json) {
                    var result=verifyResult(json);
                    if(result) {
                        search();
                    }
                }
            });
            $("#ViewHouseSourceModal").modal('hide');
            layer.msg('删除成功', {
                time: 1000, //1s后自动关闭
            });
        }, function(){
        });
    }
</script>